﻿package com.eaglesandcobras.games.scenes
{
	import com.eaglesandcobras.games.scenes.GamePage;
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	
	public class OverlayPage extends GamePage
	{	
		private var _soundController:MovieClip;
		private var _on:MovieClip;
		private var _off:MovieClip;
		
		public function OverlayPage()
		{
			super();
		}
		
		public function soundController($soundClip:MovieClip, $on:MovieClip=null, $off:MovieClip=null){
			_soundController = $soundClip;
			_soundController.mouseChildren = false;
			_soundController.buttonMode = true;
			
			_on = $on;
			_off = $off;
			
			if (_off) _off.visible = false;
			
			_soundController.addEventListener(MouseEvent.CLICK, switchSound);
		}
		
		private function switchSound(e:MouseEvent):void {
			if ( switchGlobalSound() ) {
				if (_on) _on.visible = true;
				if (_off) _off.visible = false;
			} else {
				if (_on) _on.visible = false;
				if (_off) _off.visible = true;
			}
		}
	}
}
